package rtda

import "jvm/rtda/heap"

type JFrame struct {
	lower        *JFrame
	localVars    LocalVars
	operandStack *OperandStack
	jThread      *JThread
	method       *heap.Method
	nextPC       int // the next instruction after the call
}

func newJFrame(thread *JThread, method *heap.Method) *JFrame {
	return &JFrame{
		jThread:      thread,
		method:       method,
		localVars:    newLocalVars(method.MaxLocals()),
		operandStack: newOperandStack(method.MaxStack()),
	}
}

func (jf *JFrame) OperandStack() *OperandStack {
	return jf.operandStack
}

func (jf *JFrame) LocalVars() LocalVars {
	return jf.localVars
}

func (jf *JFrame) JThread() *JThread {
	return jf.jThread
}

func (jf *JFrame) Method() *heap.Method {
	return jf.method
}

func (jf *JFrame) NextPC() int {
	return jf.nextPC
}

func (jf *JFrame) SetNextPC(nextPC int) {
	jf.nextPC = nextPC
}

func (jf *JFrame) RevertNextPC() {
	jf.nextPC = jf.jThread.pc
}
